import { LoaderManager } from "../../../../../com/gengine/resource/LoaderManager";
import { SWFInfo } from "../../../../../com/gengine/resource/info/SWFInfo";
import { _position } from "../../../../../this/_position";
type int = number;
//class CopyRewardRollItem
    
    export  class CopyRewardRollItem /* flash.display.Sprite */
    {
        constructor(arg1: int=0)
        {
            
            this._flag = arg1;
            this.mouseChildren = false;
            this.mouseEnabled = false;
            LoaderManager.instance.load("DrawRewardRect_" + arg1 % 3 + ".swf", this.onRecMcLoaded);
            return;
        }

        public get currentCount(): int
        {
            return this._currentCount;
        }

        public set currentCount(arg1: int)
        {
            this._currentCount = arg1;
            this.speed = this.updateSpeed();
            if (this._currentCount % this.speed == 0) 
            {
                this._position = this._position + 1;
            }
            if (this.position == this.lastPos && (this.fastRun || this._currentCount >= this.maxCount)) 
            {
                this.stopRunning();
            }
            return;
        }

        public stopRunning(): void
        {
            this.running = false;
            this.dispatchEvent(new Object /* flash.events.Event */(CopyRewardRollItem.RUNNING_COMPLETE));
            return;
        }

        public get position(): int
        {
            return this._flag % 2 != 0 ? (this.itemsNum - this._position % this.itemsNum - 1) : _position % this.itemsNum;
        }

        /* internal  */onRecMcLoaded(arg1: SWFInfo): void
        {
            if (!this._effect) 
            {
                this._recMc = arg1.clip;
                this._recMc.x = -181;
                this._recMc.y = -181;
                this.addChild(this._recMc);
                this._recMc.play();
            }
            return;
        }

        public setPlayEfffect(arg1: int): void
        {
            var loc1=arg1 >= 2 && arg1 <= 5 ? "DrawItemEffect_" + arg1 + ".swf" : "DrawItemEffect_2.swf";
            LoaderManager.instance.load(loc1, this.onEffectLoaded);
            return;
        }

        /* internal  */onEffectLoaded(arg1: SWFInfo): void
        {
            if (this._recMc && this._recMc.parent) 
            {
                this._recMc.stop();
                this._recMc.parent.removeChild(this._recMc);
            }
            if (!this._effect) 
            {
                this._effect = arg1.clip;
                this._effect.x = -185;
                this._effect.y = -180;
                this._effect.gotoAndPlay(1);
                this.addChild(this._effect);
            }
            return;
        }

        /* internal  */updateSpeed(): int
        {
            if (this.fastRun) 
            {
                return 1;
            }
            var loc1=this.maxCount / 6;
            if (this._currentCount < loc1 * 2) 
            {
                return 1;
            }
            if (this._currentCount < loc1 * 3) 
            {
                return 2;
            }
            if (this._currentCount < loc1 * 4) 
            {
                return 3;
            }
            if (this._currentCount < loc1 * 5) 
            {
                return 4;
            }
            if (this._currentCount < loc1 * 6) 
            {
                return 6;
            }
            return 7;
        }

        public destroy(): void
        {
            if (this._recMc) 
            {
                this._recMc.stop();
                if (this._recMc.parent) 
                {
                    this._recMc.parent.removeChild(this._recMc);
                }
                this._recMc = null;
            }
            if (this._effect) 
            {
                this._effect.stop();
                if (this._effect.parent) 
                {
                    this._effect.parent.removeChild(this._effect);
                }
                this._effect = null;
            }
            return;
        }

        public static /* const */RUNNING_COMPLETE: string="停止转动";

        public /* var */maxCount: int=50;

        public /* var */itemsNum: int=8;

        public /* var */lastPos: int;

        /* internal */ /* var */_recMc: Object /* flash.display.MovieClip */;

        /* internal */ /* var */_effect: Object /* flash.display.MovieClip */;

        public /* var */fastRun: Boolean=false;

        public /* var */running: Boolean=true;

        public /* var */speed: int=1;

        /* internal */ /* var */_currentCount: int=0;

        /* internal */ /* var */_position: int=0;

        /* internal */ /* var */_flag: int;
    }
